function loadSetGemMain() {
  $('.append').remove()
  $('#mainContent').append(template('t_setGemMain'))
  exit()
  setEquipments()
  setBagGams()
  setActionDisplay(0, 0, 0, 0)
  initPackag()
  var part, pos
  var setGemflag = 0

  $('.equipment').click(function() {
    part = $(this).attr('value')
    if (part && player.equipments[part]) {
      setGamInfo(part)
      $('.bottom').css('display', 'block')
    }
  })


  $('.punch').click(function() {
    request.punch(part, function(res) {
      showMessage('打孔成功')
      initPackag(function(){
        setEquipments(function(){
          setGamInfo(part)
        })
      })
    })
  })

  $('.setGem').click(function() {
    if (pos) {
      request.setGem(part, pos, function() {
        showMessage('镶嵌宝石成功')
        initPackag(function(){
          setBagGams()
          setEquipments(function(){
            setGamInfo(part)
          })
        })
      })
    }
  })

  $('.removeGam').click(function() {
    request.removeGam(part, function(res) {
      if (res.error === 0) {
        showMessage('摘除宝石成功')
        initPackag(function(){
          setBagGams()
          setEquipments(function(){
            setGamInfo(part)
          })
        })
      } else if (res.error === 1) {
        showMessage('仓库空间不足,请先清理仓库')
      }
    })
  })


  function setGamInfo(part) {
    $('.equipment').removeClass('select')
    $('.' + part).addClass('select')
    $('.setInfo').html('')
    $('.gem').removeClass('select')
    var equipment = player.equipments[part]
    var solt = equipment.solt
    var gemConfig = templateConfig.other[290040][equipment.quality]
    console.log(gemConfig)
    var lackFlag = 0
    if (solt.length <= 0) {
      $('.soltCon').html('无孔')
      var propId = gemConfig.needProp[0]
      var needNum = gemConfig.needProp[1]
      var num = getTotalNumByItemId(240003)
      if (num < needNum) {
        lackFlag = 1
      }
      $('.needProp').html(propName[propId] + '(' + num + ') X ' + needNum)
      if (gemConfig.needMoney1) {
        $('.needMoney').html('银币(' + player.basicInfo.money + ')X' + gemConfig.needMoney1 * equipment.lvl)
        if (player.basicInfo.money < gemConfig.needMoney1 * equipment.lvl)
          lackFlag = 2
      }
      if (gemConfig.needGold1) {
        $('.needMoney').html('金币(' + player.basicInfo.money + ')X' + gemConfig.needGold1 * equipment.lvl)
        if (player.basicInfo.gold < gemConfig.needGold1 * equipment.lvl)
          lackFlag = 3
      }
      setGemflag = 0
      setActionDisplay(1, 0, 0, 0)
    } else if (solt[0]) {
      setActionDisplay(0, 0, 1, 0)
      $('.soltCon').html(propName[solt[0]])
      $('.needProp').html('')
      if (gemConfig.needMoney3) {
        $('.needMoney').html('银币(' + player.basicInfo.money + ')X' + gemConfig.needMoney3 * equipment.lvl)
        if (player.basicInfo.gold < gemConfig.needMoney3 * equipment.lvl)
          lackFlag = 2
      }
      if (gemConfig.needGold3) {
        $('.needMoney').html('金币(' + player.basicInfo.money + ')X' + gemConfig.needGold3 * equipment.lvl)
        if (player.basicInfo.gold < gemConfig.needGold3 * equipment.lvl)
          lackFlag = 3
      }
      setGemflag = 0
    } else if (!solt[0]) {
      $('.needProp').html('放入宝石')
      $('.soltCon').html('空孔')
      setGemflag = 1
      if (gemConfig.needMoney2) {
        $('.needMoney').html('银币(' + player.basicInfo.money + ')X' + gemConfig.needMoney2 * equipment.lvl)
        if (player.basicInfo.gold < gemConfig.needMoney2 * equipment.lvl)
          lackFlag = 2
      }
      if (gemConfig.needGold2) {
        $('.needMoney').html('金币(' + player.basicInfo.money + ')X' + gemConfig.needGold2 * equipment.lvl)
        if (player.basicInfo.gold < gemConfig.needGold2 * equipment.lvl)
          lackFlag = 3
      }
      setActionDisplay(0, 0, 0, 0)
    }

    if (lackFlag) {
      setActionDisplay(0, 0, 0, 1)
      if (lackFlag === 1) {
        $('.lack').html('材料不足')
      } else if (lackFlag === 2) {
        $('.lack').html('银币不足')
      } else if (lackFlag === 3) {
        $('.lack').html('金币不足')
      }
    }
  }

  function setBagGams() {
    initPackag(function() {
      var items = player.bag.items
      $('.gem').remove()
      for (var i in items) {
        if (items[i]) {
          var templateId = items[i].templateId
          type = Math.floor(templateId / 10000)
          if (type === 25) {
            $('.gems').append('<div class="gem" value="' + i + '">' + propName[templateId] + ' X' + items[i].stack + '</div>')
          }
        }
      }

      $('.gem').click(function() {
        $('.gem').removeClass('select')
        if (setGemflag) {
          pos = parseInt($(this).attr('value'))
          $(this).addClass('select')
          var templateId = player.bag.items[pos].templateId
          $('.needProp').html(propName[templateId])
          setActionDisplay(0, 1, 0, 0)

          var itemConfig = templateConfig.total[templateId]
          $('.setInfo').html('<div class="desc">' + propName[templateId] + '<br>' + itemConfig.desc + '</div>')
        }
      })
    })
  }


  function setActionDisplay(flag1, flag2, flag3, flag4, flag5) {
    if (flag1) {
      $('.punch').css('display', 'block')
    } else {
      $('.punch').css('display', 'none')
    }

    if (flag2) {
      $('.setGem').css('display', 'block')
    } else {
      $('.setGem').css('display', 'none')
    }

    if (flag3) {
      $('.removeGam').css('display', 'block')
    } else {
      $('.removeGam').css('display', 'none')
    }

    if (flag4) {
      $('.lack').css('display', 'block')
    } else {
      $('.lack').css('display', 'none')
    }
  }
}
